<template>
  <view class="accept-box" :class="color" @click="handleClick">
    <view class="check-box">
      <view class="acept-check">
        <view v-if="askYes == options[1]" class="active"></view>
      </view>
    </view>
    <slot></slot>
  </view>
</template>

<script>
export default {
  props: {
    value: {
      type: String,
    },
    color: {
      type: String,
    },
  },
  data() {
    return {
      askYes: '',
      options: ['0', '1'],
    };
  },
  watch: {
    value: {
      handler(val) {
        this.askYes = val;
      },
      immediate: true,
    },
  },
  methods: {
    handleClick() {
      this.askYes =
        this.askYes == this.options[0] ? this.options[1] : this.options[0];
      this.$emit('input', this.askYes);
    },
  },
};
</script>

<style lang="less" scoped>
.accept-box {
  color: #fff;
  font-size: 22rpx;
  line-height: 36rpx;
  display: flex;
  flex-direction: row;
}
.black {
  color: #444;
}
.check-box {
  margin-right: 20rpx;
  padding-top: 4rpx;
}
.acept-check {
  height: 24rpx;
  width: 24rpx;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #ffffff;
  .active {
    width: 60%;
    height: 60%;
    background-color: #7e7e7e;
  }
}
.black {
  .acept-check {
    background-color: #7e7e7e;
    .active {
      background-color: #ffffff;
    }
  }
}
</style>
